/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.factory;

import java.util.ArrayList;
import java.util.Collection;
import ru.jSky.CompositeMod;
import ru.jSky.support.GrupTypeBuilder;
import ru.jSky.JSkyGlobal;
import ru.jSky.ModImporter;
import ru.jSky.finder.FinderByEdid;
import ru.jSky.finder.FromModByEdidFinder;
import ru.jSky.interfaces.Armor;
import ru.jSky.interfaces.Enchantment;
import ru.jSky.interfaces.FormList;
import ru.jSky.interfaces.JSkyMod;
import ru.jSky.interfaces.Keyword;
import ru.jSky.interfaces.LeveledItemList;
import ru.jSky.interfaces.Major;
import ru.jSky.selector.AbstractFromModByEdidSelector;
import ru.jSky.selector.SelectorByEdid;
import skyproc.FormID;
import skyproc.GRUP_TYPE;

/**
 *
 * @author Rakev
 */
public class GlobalSelectorByEdidFactory {

    private static GlobalSelectorByEdidFactory instance = new GlobalSelectorByEdidFactory();

    public static GlobalSelectorByEdidFactory create() {
        return instance;
    }

    protected GlobalSelectorByEdidFactory() {
    }

    public SelectorByEdid<Keyword> createKeywordSelector() {
        return new AbstractFromModByEdidSelector<Keyword>() {
            @Override
            protected Collection<Keyword> getExistMajors() {
                return getLookingMod().getKeywords();
            }
        };
    }

    public SelectorByEdid<Armor> createArmorSelector() {
        return new AbstractFromModByEdidSelector<Armor>() {
            @Override
            protected Collection<Armor> getExistMajors() {
                return getLookingMod().getArmors();
            }
        };
    }

    public SelectorByEdid<Enchantment> createEnchantmentSelector() {
        return new AbstractFromModByEdidSelector<Enchantment>() {
            @Override
            protected Collection<Enchantment> getExistMajors() {
                return getLookingMod().getEnchantments();
            }
        };
    }

    private JSkyMod getLookingMod() {
        Collection<JSkyMod> importedMods = ModImporter.getInstance().getImportedMods();
        Collection<JSkyMod> lookingMods = new ArrayList<>(importedMods);
        lookingMods.add(JSkyGlobal.getInstance().getEditingMod());
        return new CompositeMod(lookingMods);
    }
}
